package com.liangzhong.view.tips
{
	import com.common.utils.DisplayObjectUtil;
	import com.common.utils.Reflection;
	import com.liangzhong.constants.ClubConst;
	import com.liangzhong.model.goods.vo.PlayerStarVo;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import lz.controls.tips.ITip;

	/**
	 *球员卡tips  
	 * @author lake
	 * 
	 */	
	public class PlayerCardTips extends Sprite implements ITip
	{
		/**
		 *静态全局公用 
		 */		
		public static var symbolSkin		:MovieClip;//皮肤
		/**
		 * 数据
		 */		
		private var _data :Object;
		
		public function PlayerCardTips()
		{
			super();
		}
		/**
		 *设置获取数据 
		 * @return 
		 * 
		 */		
		public function get data():Object
		{
			return _data;
		}
		public function set data(value:Object):void
		{
			_data = value;
			if(symbolSkin == null)
			{
				symbolSkin = Reflection.createInstance("com.liangzhong.ui.playCard");
			}
			this.addChild(symbolSkin);
			showData(symbolSkin);
		}
		/**
		 *显示数据 
		 */		
		public function showData(symbolSkin :MovieClip):void
		{
			var star :PlayerStarVo = _data as PlayerStarVo;
			if(star == null)
			{
				return;
			}
			symbolSkin.gotoAndStop(star.color);
			symbolSkin.mc.txtLv.text 			= "" + star.level;
			symbolSkin.mc.txtName.text 			= "" + star.pname;
			
			symbolSkin.mc.ability.text 			= ""+ star.ability;
			symbolSkin.mc.txtattack.text 		= "" + star.attack;
			symbolSkin.mc.txtdefence.text 		= "" + star.defence;
			symbolSkin.mc.txtsteal.text 		= "" + star.steal;
			symbolSkin.mc.txtpower.text 		= "" + star.power;
			symbolSkin.mc.txtspeed.text 		= "" + star.speed;
			symbolSkin.mc.txtcontrol.text 		= "" + star.control;
			var frameIndex :int = 1;
			var maxValue   :int = ClubConst.colorToPro(star.color);
			/*frameIndex = star.attack / maxValue * 11;
			symbolSkin.mc.attackProMc.gotoAndStop(frameIndex);
			frameIndex = star.defence / maxValue * 11;
			symbolSkin.mc.defenceProMc.gotoAndStop(frameIndex);
			frameIndex = star.steal / maxValue * 11;
			symbolSkin.mc.stealProMc.gotoAndStop(frameIndex);
			frameIndex = star.power / maxValue * 11;
			symbolSkin.mc.powerProMc.gotoAndStop(frameIndex);
			frameIndex = star.speed / maxValue * 11;
			symbolSkin.mc.speedProMc.gotoAndStop(frameIndex);
			frameIndex = star.control / maxValue * 11;
			symbolSkin.mc.controlProMc.gotoAndStop(frameIndex);*/
			var showW :Number = 0;
			showW = star.attack / maxValue * 70;
			symbolSkin.mc.attackProMc.pmc.width = showW;
			showW = star.defence / maxValue * 70;
			symbolSkin.mc.defenceProMc.pmc.width = showW;
			showW = star.steal / maxValue * 70;
			symbolSkin.mc.stealProMc.pmc.width = showW;
			showW = star.power / maxValue * 70;
			symbolSkin.mc.powerProMc.pmc.width = showW;
			showW = star.speed / maxValue * 70;
			symbolSkin.mc.speedProMc.pmc.width = showW;
			showW = star.control / maxValue * 70;
			symbolSkin.mc.controlProMc.pmc.width = showW;
			
			symbolSkin.mc.txtPlace.text = "" + star.placeName;
			//大头像
			var bigImgBg :MovieClip = symbolSkin.mc.bigImgBg;
			var bigBData :BitmapData = star.bigBitmapData;
			var bigBitMap :Bitmap = new Bitmap(bigBData);
			DisplayObjectUtil.removeAllChildren(bigImgBg.pContainer);
			if(bigImgBg)
			{
				bigImgBg.pContainer.addChild(bigBitMap);
			}
		}
		/**
		 * 设置数据 多个元件 
		 * @param value
		 * 
		 */		
		public function set cdata(value :Object):void
		{
			_data = value;
			var sbolSkin :MovieClip = Reflection.createInstance("com.liangzhong.ui.playCard");
			this.addChild(sbolSkin);
			showData(sbolSkin);
		}
		/**
		 *设置数据 同一 symbolSkin 通用
		 * @param value
		 * @param symbolSkin
		 * 
		 */		
		public function setPureData(value :Object,sbolSkin :MovieClip):void
		{
			_data = value;
			showData(sbolSkin);
		}
		/**
		 * 销毁
		 */		
		public function destroy():void
		{
			_data = null;
		}
	}
}